package com.example.demo11.service;

import com.example.demo11.dao.RoleDao;
import com.example.demo11.entity.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleDao rolerDao;

    @Override
    public List<Map<String, Object>> findByName(String name) {
        return rolerDao.findByName(name);
    }

    @Override
    public Role findById(Integer id) {
        return rolerDao.findById(id);
    }

    @Override
    public List<Map<String, Object>> findRoleByUserName(String name) {
        return rolerDao.findRoleByUserName(name);
    }

    @Override
    public List<Map<String, Object>> findUserByRoleName(String name) {
        return rolerDao.findUserByRoleName(name);
    }

    @Override
    public int deleteId(Integer id) {
        return rolerDao.delete(id);
    }

    @Override
    public int addUser(Role user) {
        return rolerDao.add(user);
    }

    @Override
    public int updateUser(Role user) {
        return rolerDao.update(user);
    }

    @Override
    public List<Map<String, Object>> findRoleByUserId(Integer id) {
        return rolerDao.findRoleByUserId(id);
    }

    @Override
    public List<Map<String, Object>> findUserByRoleId(Integer id) {
        return rolerDao.findRoleByUserId(id);
    }

    @Override
    public List<Map<String, Object>> findAll(Integer page) {
        return rolerDao.findAll(page);
    }

}